<?php
    session_start();
    if ( $_SESSION['ID'] == "" ) {
        echo "Please Login!";
        exit();
    }
    if ( $_SESSION['STATUS'] != "ADMIN"  ) {
        exit();
    }
?>
<html>
    <head>
        <title>ระบบสารสนเทศภูมิศาสตร์เพื่อการตัดสินใจ (Gis-DSS : GIS Decision SupportSystem) ด้านวิศวกรรม</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.js"></script>
        <script type="text/javascript" src="js/adminpage.js"></script>
    </head>
    <style>
        #TableAdmin{
            margin: auto;
            margin-left: auto;
            position: relative;
        }
        /* Show priority 1 at 320px (20em x 16px) */
        .ui-dialog-contain {
            width: 92.5%;
            max-width: 350px;
            margin: 6% auto 15px auto;
            padding: 10px;
            position: relative;
            top: -15px;
        }
        #HelloUser{
            font-size: 14px; 
            color: white; 
            text-shadow: black 0.1em 0.1em 0.2em;
            position: absolute;
            top: 14px; 
            right: 5px; 
            margin-right: 130px; 
            width:150px;
        }
    </style>
    <body Onload="AjaxListPage('1')">   
        <div data-role="page">
            <div id="headerID" data-role="header" data-theme="b" data-position="fixed">
                <h1 style="position: relative;">Table Editor Admin</h1>
                <a id="logout" href="#" data-icon="delete"  data-transition="flip" class="ui-btn-right" >ออกจากระบบ</a>                                

                <a href="#popupAdminAddUser" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="plus" data-transition="slide"class="ui-btn-left" >สมัครสมาชิก</a>
                <a href="#" onclick="showSearchID()" data-role="button" data-inline="true" data-icon="search" data-transition="pop" class="ui-btn-left" style="left: 130px;" >ค้นหาข้อมูล</a>   
                 <div id="HelloUser">
                    <? if ( $_SESSION['USER_ID'] != "" ) {
                        echo "สวัสดีคุณ"." ".$_SESSION['USER_ID'];
                    }?>
                </div>                     

            </div>
           
            <div data-role="content" id="TableAdmin"  >
               
                <div id="SearchID" style="display: none; ">
                    <table width="640" border=1">

                        <h3>ค้นหาข้อมูล</h3>
                        <tr class="ui-bar-d" >

                            <td><div><input type="search" name="search-1" id="textSearchID" value="" ></div></td>                            
                            <td align="center" ><input type="button" data-iconpos="notext" id="ButtonSearch"  data-iconpos="right" data-icon="search" data-role="button"   data-theme="c" data-inline="true"  name="btnUpdate" id="btnUpdate" value="UPDATE" onclick="Ajaxsearch()"></td>
                        </tr>
                    </table>
                </div>
                <br>

                <div  id="table-custom-2" ></div>                 
                <br>
                <br>
                <div id="ShowEditForm">
                    <span id="myForm" style="display: none;">

                        <table width="640" border="1">
                            <thead>
                                <tr class="ui-bar-d">
                                    <th >ID</th>
                                    <th >USER_ID</th>
                                    <th >PASSWORD</th>
                                    <th >PID</th>
                                    <th >E-MAIL</th>
                                    <th >STATUS</th> 
                                    <th >UPDATE</th> 
                                </tr>
                            </thead>
                            <tr>
                            <tr class="ui-bar-d">
                                <td><div align="center"><input type="text" name="ID" id="textID" size="5" disabled="true" style="width: 30px;"></div></td>
                                <td><input type="text" name="txtAdminUsername" id="txtAdminUsername" style="width: 150px; position: relative;"></td>
                                <td><input type="password" name="txtAdminPassword" id="txtAdminPassword" style="width: 150px; position: relative;"></td>
                                <td><div align="center"><input type="text" name="txtAdminPID" id="txtAdminPID" style="width: 130px; position: relative;"></div></td>
                                <td align="right"><input type="text" name="txtEmail" id="txtEmail" style="width: 200px; position: relative;"></td>

                                <td style="width: 50px; position: relative;">
                                    <select name="txtStatus" id="txtStatus" data-mini="true" >                                                
                                        <option >USER</option>
                                        <option >ADMIN</option>                            
                                    </select> 
                                </td>
                                <td align="center" ><input type="button"  data-iconpos="right"  data-role="button" data-icon="edit"  data-theme="c" data-inline="true" data-mini="true" name="btnUpdate" id="btnUpdate" value="UPDATE" onclick="AjaxUpdate()"></td>
                            </tr>
                        </table>

                        <br><br>
                    </span>
                </div>
                <!------------------------------------------------------------------------------------------------------------------------------------->

                <div data-role="popup" id="popup" data-theme="b">
                    <div data-role="popup" id="popupAdminAddUser" data-theme="b" class="ui-corner-all" >
                        <form>
                            <div style="padding:10px 20px;">
                                <h3 style="text-align: center;">Register By Admin</h3>

                                <label for="un" class="ui-hidden-accessible" >Username:</label>
                                <input maxlength = 16 type="text" name="txtUsernameByAdmin" id="txtUsernameByAdmin" value="" placeholder="กรุณากรอกชื่อของคุณ" data-theme="a">
                                <label for="pw" class="ui-hidden-accessible">Password:</label>
                                <input maxlength = 16 type="password" name="txtPasswordByAdmin" id="txtPasswordByAdmin" value="" placeholder="กรุณากรอกพาสเวิดของคุณ" data-theme="a">

                                <label for="un" class="ui-hidden-accessible" >PID:</label>
                                <input maxlength = 13 type="text" name="txtPIDByAdmin" id="txtPIDByAdmin" value="" placeholder="กรุณากรอกรหัสบัตรประชาชนของคุณ" data-theme="a">
                                <label for="un" class="ui-hidden-accessible" >E-MAIL:</label>
                                <input maxlength = 80 type="text" name="txtEmailByAdmin" id="txtEmailByAdmin" value="" placeholder="กรุณากรอกอีเมลล์ของคุณ" data-theme="a">
                                <label for="un" class="ui-hidden-accessible" >STATUS:</label>
                                <div style="width: 200px;position: relative;">
                                    <select  name="txtStatusByAdmin" id="txtStatusByAdmin" data-mini="true">                                                
                                        <option value="USER" >user</option>
                                        <option value="ADMIN">admin</option>                            
                                    </select>
                                </div>
                                <!--button data-mini="true" type="submit" data-theme="b" data-icon="plus" data-iconpos="right" onclick="GettextAdmin()">ADD</button-->
                                <button  id="adduser" data-mini="true" type="button" data-theme="b" data-icon="plus" data-iconpos="right">ADD</button>

                            </div>
                        </form>
                    </div>
                </div>
                <!----------------------------------------------------------------------------------------------------------------------->                

            </div>  


            <div data-role="footer" data-position="fixed">
                <h1>การประปานครหลวง ฝ่ายมาตรฐานวิศวกรรมและสารสนเทศภูมิศาสตร์ กองสารสนเทศภูมิศาสตร์ tel.1781</h1>
            </div>                                
        </div> 

    </body>

</html>